package demo;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: rei
 * Date: 2025-11-26
 * Time: 17:02
 */
public class OutputStream {
    public static void main(String[] args) throws IOException {
        File file = new File("c:/temp/123.txt");
        //file.createNewFile();

        //创建一个输出流
        FileOutputStream outputStream = new FileOutputStream(file);
        //调用write方法,是将程序内存区的数据写入系统缓存区,缓存区写入文件是操作系统做的,
        // 我们不知道是什么时候
        outputStream.write(97);
        outputStream.write(98);
        outputStream.write(99);
        outputStream.write(14);
        outputStream.write(10);

        //刷新缓存区 强制操作系统刷新 ,落盘,不会因为系统奔溃导致数据流失
        outputStream.flush();

        //关闭流
        outputStream.close();

    }
}
